﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class MatterPlanarFoldMachine2PlcActionBO
    {
        /// <summary>
        /// 当前设备号
        /// </summary>
        public string EquipmentCode { get; set; }

        /// <summary>
        /// 任务号
        /// </summary>
        public int TaskCode { get; set; }
        /// <summary>
        /// 目标设备号
        /// </summary>
        public int ToEquipmentCode { get; set; }

        /// <summary>
        /// 母托盘条码
        /// </summary>
        public string PalletBarcode { get; set; }
        /// <summary>
        /// 母托盘重量
        /// </summary>
        public short PalletWeight { get; set; }
        /// <summary>
        /// 子托盘码1
        /// </summary>
        public string PalletBarcode1 { get; set; }
        /// <summary>
        /// 子托盘码2
        /// </summary>
        public string PalletBarcode2 { get; set; }
        /// <summary>
        /// 子托盘码3
        /// </summary>
        public string PalletBarcode3 { get; set; }
        /// <summary>
        /// 子托盘码4
        /// </summary>
        public string PalletBarcode4 { get; set; }
        /// <summary>
        /// 子托盘码5
        /// </summary>
        public string PalletBarcode5 { get; set; }
        /// <summary>
        /// 子托盘码6
        /// </summary>
        public string PalletBarcode6 { get; set; }
        /// <summary>
        /// 子托盘码7
        /// </summary>
        public string PalletBarcode7 { get; set; }
        /// <summary>
        /// 子托盘码8
        /// </summary>
        public string PalletBarcode8 { get; set; }
        /// <summary>
        /// 子托盘1重量
        /// </summary>
        public short PalletWeight1 { get; set; }
        /// <summary>
        /// 子托盘2重量
        /// </summary>
        public short PalletWeight2 { get; set; }
        /// <summary>
        /// 子托盘3重量
        /// </summary>
        public short PalletWeight3 { get; set; }
        /// <summary>
        /// 子托盘4重量
        /// </summary>
        public short PalletWeight4 { get; set; }
        /// <summary>
        /// 子托盘5重量
        /// </summary>
        public short PalletWeight5 { get; set; }
        /// <summary>
        /// 子托盘6重量
        /// </summary>
        public short PalletWeight6 { get; set; }
        /// <summary>
        /// 子托盘7重量
        /// </summary>
        public short PalletWeight7 { get; set; }
        /// <summary>
        /// 子托盘8重量
        /// </summary>
        public short PalletWeight8 { get; set; }
        /// <summary>
        /// 动作类型
        /// </summary>
        public short ActionType { get; set; }
        /// <summary>
        /// 托盘类型
        /// </summary>
        public byte PalletType { get; set; }
        /// <summary>
        /// 故障代码
        /// </summary>
        public byte AlrmCode { get; set; }
        /// <summary>
        /// 是否单机任务
        /// </summary>
        public byte SignalTask { get; set; }
        /// <summary>
        /// 预留2
        /// </summary>
        public byte Reserve2 { get; set; }
        /// <summary>
        /// 预留3
        /// </summary>
        public byte Reserve3 { get; set; }
        /// <summary>
        /// 预留4
        /// </summary>
        public byte Reserve4 { get; set; }


        /// <summary>
        /// agv任务号
        /// </summary>
        public string AgvTaskCode { get; set; }



        public void Serialize(byte[] bytes)
        {



            EquipmentCode = HelperByte.GetDIntAt(bytes, 0).ToString();
            TaskCode = HelperByte.GetDIntAt(bytes, 4);
            ToEquipmentCode = HelperByte.GetDIntAt(bytes, 8);

            int length = HelperByte.GetSIntAt(bytes, 13);
            PalletBarcode = HelperByte.GetCharsAt(bytes, 14, length);

            PalletWeight = HelperByte.GetIntAt(bytes, 32);

            int lengthPalletBarcode1 = HelperByte.GetSIntAt(bytes, 35);
            PalletBarcode1 = HelperByte.GetCharsAt(bytes, 36, lengthPalletBarcode1);
            int lengthPalletBarcode2 = HelperByte.GetSIntAt(bytes, 55);
            PalletBarcode2 = HelperByte.GetCharsAt(bytes, 56, lengthPalletBarcode2);
            int lengthPalletBarcode3 = HelperByte.GetSIntAt(bytes, 75);
            PalletBarcode3 = HelperByte.GetCharsAt(bytes, 76, lengthPalletBarcode3);
            int lengthPalletBarcode4 = HelperByte.GetSIntAt(bytes, 95);
            PalletBarcode4 = HelperByte.GetCharsAt(bytes, 96, lengthPalletBarcode4);
            int lengthPalletBarcode5 = HelperByte.GetSIntAt(bytes, 115);
            PalletBarcode5 = HelperByte.GetCharsAt(bytes, 116, lengthPalletBarcode5);
            int lengthPalletBarcode6 = HelperByte.GetSIntAt(bytes, 135);
            PalletBarcode6 = HelperByte.GetCharsAt(bytes, 136, lengthPalletBarcode6);
            int lengthPalletBarcode7 = HelperByte.GetSIntAt(bytes, 155);
            PalletBarcode7 = HelperByte.GetCharsAt(bytes, 156, lengthPalletBarcode7);
            int lengthPalletBarcode8 = HelperByte.GetSIntAt(bytes, 175);
            PalletBarcode8 = HelperByte.GetCharsAt(bytes, 176, lengthPalletBarcode8);

            PalletWeight1 = HelperByte.GetIntAt(bytes, 194);
            PalletWeight2 = HelperByte.GetIntAt(bytes, 196);
            PalletWeight3 = HelperByte.GetIntAt(bytes, 198);
            PalletWeight4 = HelperByte.GetIntAt(bytes, 200);
            PalletWeight5 = HelperByte.GetIntAt(bytes, 202);
            PalletWeight6 = HelperByte.GetIntAt(bytes, 204);
            PalletWeight7 = HelperByte.GetIntAt(bytes, 206);
            PalletWeight8 = HelperByte.GetIntAt(bytes, 208);
            ActionType = HelperByte.GetIntAt(bytes, 210);
            PalletType = HelperByte.GetByteAt(bytes, 212);
            AlrmCode = HelperByte.GetByteAt(bytes, 213);
            SignalTask = HelperByte.GetByteAt(bytes, 214);
            Reserve2 = HelperByte.GetByteAt(bytes, 215);
            Reserve3 = HelperByte.GetByteAt(bytes, 216);
            Reserve4 = HelperByte.GetByteAt(bytes, 217);

            int lengthAgvTaskCode = HelperByte.GetSIntAt(bytes, 219);
            AgvTaskCode = HelperByte.GetCharsAt(bytes, 220, lengthAgvTaskCode);
        }
    }
}
